package com.qfedu.knowledge.controller;

import com.qfedu.knowledge.entity.bo.RightsBO;
import com.qfedu.knowledge.entity.vo.ResultVO;
import com.qfedu.knowledge.service.IRightsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName RightsController
 * @Author ykx
 * @Date 2024/4/26 21:54
 * @Version 1.0
 */
@RestController
@RequestMapping("/knowledge")
public class RightsController {

    @Autowired
    private IRightsService rightsService;

    @GetMapping("/rights/list")
    public ResultVO getRightsList() {
        return ResultVO.success(rightsService.getRightsList());
    }

    @DeleteMapping("/rights/{id}")
    public ResultVO deleteRights(@PathVariable Integer id) {
        return ResultVO.success(rightsService.removeById(id));
    }

    @PutMapping("/rights/{id}")
    public ResultVO updateRights(@PathVariable Integer id, @RequestBody RightsBO rightsBO) {
        rightsBO.setId(id);
        return ResultVO.success(rightsService.updateById(rightsBO));
    }

}
